const concurrently = require('concurrently')
const dotenv = require('dotenv');
const path = require('path');

// 获取环境变量
const {parsed} = dotenv.config({
  path: path.resolve(__dirname, '../.env')
})

let argv = process.argv.slice(2)
console.log(argv[0])
parsed.PORT = argv[0]||parsed.PORT
// const envConfig2 = dotenv.parse(fs.readFileSync(path.resolve(__dirname, '../.env')));
// 注入环境变量
concurrently([
  {
    command: 'umi dev',
    name: 'react',
    env: parsed,
    prefixColor: '#61dafb'
  },
  {
    command: 'node script/build_main.js --watch',
    name: 'electron',
    env: parsed,
    prefixColor: '#f60'
  }
], {})
